import SOAPpy as SOAP
import time, sys

if len(sys.argv) > 1: fname = sys.argv[1]
else: print "No file given"; sys.exit(0)

t = time.time()
server = SOAP.SOAPProxy("http://localhost:8080/")
data = server.fetch_file(fname)

try:
	open(fname)
	fname = '_'+fname
	f = file(fname, 'wb')
except:
	f = file(fname, 'wb')

try:
	for c in data.split('.'):
		if c == '': continue
		dump = chr(int(c))
		f.write(dump)
	t = time.time() - t
	
	print 'Success writing %sB to %s\nTook %isecs' % (len(data), fname, t)
except:
	print 'Failed to write %s' % fname

